<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/init.jsp"%>

<script type="text/javascript">
	function query() {
		//$("#form1").submit();
	}
	function myAdd() {
		var bank_id = $("input[name='bank_id']").val();
		var url = "${path}/ix/user/info/add_form.htm?bank_id=" + bank_id;
		add_and_edit(url);
	}
	function goDetail(user_id) {

		var url = "${path}/ix/user/info/edit_form.htm?user_id=" + user_id;
		add_and_edit(url);
	}
	function repass(user_id) {
		if (confirm("重置后密码为：123456")) {
			$.ajax({
				type : "post",
				url : "${path}/ix/user/info/repass.htm",
				data : {
					user_id : user_id
				},
				cache : false,
				success : function(data) {
					if (data) {
						ohSnap("已重置", "success");
					}
				}
			});
		}
	}
	function goDel(user_id) {
		$("input[name='user_id']").val(user_id);

		var url = "${path}/ix/user/info/del.htm";
		$("#form1").attr("action", url);
		$("#form1").submit();
	}

	function user(sta, user_id) {

		if (confirm("确认该操作吗？")) {
			$.ajax({
				type : "post",
				url : "${path}/ix/user/info/sta.htm",
				data : {
					sta : sta,
					user_id : user_id
				},
				success : function(data) {
					var tr = $("#" + user_id)
					tr.text(sta);
					tr.next().text("");
					ohSnap("已提交", "success");
				}

			});
		}

	}

	$(function() {
		var $tr = $(".sta");
		$.each($tr, function(i, n) {
			var tr = $tr.eq(i).text();
			if (tr == "正常") {
				$tr.eq(i).next().find('a').eq(1).hide();
			} else {

				if (tr == "停用") {
					$tr.eq(i).next().find('a').eq(0).hide();
					$tr.eq(i).next().find('a').eq(2).hide();
					$tr.eq(i).next().find('a').eq(3).hide();
					$tr.eq(i).next().find('a').eq(4).hide();
				} else {
					$tr.eq(i).next().text("");
				}

			}
		});

	});
</script>

<div>
	<form action="${path}/ix/user/info/list.htm" id="form1" method="post">
		<input type="hidden" name="user_id" /> <input type="hidden"
			name="bank_id" value="${bank._id}" />
		<h2>
			<div>人员管理</div>
		</h2>


		<table width="100%" class="listlindex">
			<tr>
				<th>人员代码</th>
				<th>职位</th>
				<th>人员名称</th>
				<th>身份证</th>
				<th>所属机构</th>
				<th>登录状态</th>
				<th>人员状态</th>
				<th>操作</th>
			</tr>
			<c:if test="${fn:length(userList)==0}">
				<tr>
					<td colspan="8"><div class="tip_div">暂无记录.</div></td>
				</tr>
			</c:if>
			<c:forEach items="${userList}" var="v">
				<tr>
					<td>${v.code}</td>
					<td>${v.job}</td>
					<td>${v.uname}</td>
					<td>${v.p_id}</td>
					<td>${bank.name}</td>
					<td>${v.is_live}</td>
					<td id="${v._id}" class="sta">${v.user_flag}</td>
					<td><a href="javascript:user('停用待审核','${v._id}');"
						class="asave">【停用用户】</a> <a
						href="javascript:user('启用待审核','${v._id}');" class="asave">【启用用户】</a>&nbsp;&nbsp;&nbsp;
						<a href="javascript:goDetail('${v._id}');">【修改】</a> <a
						href="javascript:user('删除待审核','${v._id}');">【删除】</a> <a
						href="javascript:repass('${v._id}');">【重置密码】</a></td>

				</tr>
			</c:forEach>

			<tr>
				<td  colspan="8">
					<a href="javascript:myAdd();" style = "float:left;">【添加】</a>
					<c:if test="${fn:length(userList)!=0}">
						<page:page page="${page}" is_ajax="true"
								ajax_id="add_edit_form" />
					</c:if>
				</td>
			</tr>


		</table>
		<div id="response"></div>
	</form>

</div>
